package o;

import androidx.annotation.NonNull;
import com.bumptech.glide.load.engine.GlideException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import o.hg.e;

public class ts<Data, ResourceType, Transcode> {
    private final String ˋ;
    private final List<? extends ti<Data, ResourceType, Transcode>> ˎ;
    private final e<List<Throwable>> ˏ;
    private final Class<Data> ॱ;

    public ts(Class<Data> cls, Class<ResourceType> cls2, Class<Transcode> cls3, List<ti<Data, ResourceType, Transcode>> list, e<List<Throwable>> eVar) {
        this.ॱ = cls;
        this.ˏ = eVar;
        this.ˎ = (List) aas.ˏ((Collection) list);
        this.ˋ = "Failed LoadPath{" + cls.getSimpleName() + "->" + cls2.getSimpleName() + "->" + cls3.getSimpleName() + "}";
    }

    public tx<Transcode> ˏ(sl<Data> slVar, @NonNull sc scVar, int i, int i2, d<ResourceType> dVar) throws GlideException {
        List list = (List) aas.ˎ(this.ˏ.ˎ());
        try {
            tx<Transcode> ॱ = ॱ(slVar, scVar, i, i2, dVar, list);
            return ॱ;
        } finally {
            this.ˏ.ˋ(list);
        }
    }

    private tx<Transcode> ॱ(sl<Data> slVar, @NonNull sc scVar, int i, int i2, d<ResourceType> dVar, List<Throwable> list) throws GlideException {
        tx<Transcode> ˋ;
        tx<Transcode> txVar = null;
        int size = this.ˎ.size();
        int i3 = 0;
        while (i3 < size) {
            try {
                ˋ = ((ti) this.ˎ.get(i3)).ˋ(slVar, i, i2, scVar, dVar);
            } catch (GlideException e) {
                list.add(e);
                ˋ = txVar;
            }
            if (ˋ != null) {
                break;
            }
            i3++;
            txVar = ˋ;
        }
        ˋ = txVar;
        if (ˋ != null) {
            return ˋ;
        }
        throw new GlideException(this.ˋ, new ArrayList(list));
    }

    public String toString() {
        return "LoadPath{decodePaths=" + Arrays.toString(this.ˎ.toArray()) + '}';
    }
}
